package team.bailan.controller;

import com.auth0.jwt.JWT;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import team.bailan.common.util.NeedVerify;

@RestController
@RequestMapping("api")
public class HelloController {
    @GetMapping("hello")
    @NeedVerify
    public String hello() {
        return "hello world";
    }

    @GetMapping("verify")
    public int verifyToken(@RequestParam String token) {
        return Integer.parseInt(JWT.decode(token).getAudience().get(0));
    }
}
